package com.example;

import java.sql.Connection;
import java.sql.Driver;
import java.sql.SQLException;
import java.util.Properties;

public class Main {
    public static void main(String[] args) throws Exception{
        connect_postgres("postgres", "nopass");
    }

    public static void connect_postgres(String username, String password) throws Exception{
        Driver driver = new org.postgresql.Driver();

        Properties properties = new Properties();
        properties.setProperty("user", username);
        properties.setProperty("password", password);

        Connection connection = driver.connect("jdbc:postgresql://localhost:5432/test", properties);
        System.out.println("PostgreSQL success");
    }

    public static void connect_mysql(String username, String passwd) throws Exception{
        Driver driver = new com.mysql.jdbc.Driver();

        Properties properties = new Properties();
        properties.setProperty("user", username);
        properties.setProperty("password", passwd);

        Connection connection = driver.connect("jdbc:mysql://localhost:3306/test", properties);
        System.out.println("MySQL success");
    }
}
